package cn.shujuhai.common.service.impl;

import cn.shujuhai.common.domain.SysOperationLog;
import cn.shujuhai.common.domain.SysUser;
import cn.shujuhai.common.mapper.SysOperationLogMapper;
import cn.shujuhai.common.pluging.data.ResultVo;
import cn.shujuhai.common.service.SysOperationLogService;
import cn.shujuhai.common.service.SysUserService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author NiuYahu
 * @description 针对表【sys_operation_log(后台操作日志表)】的数据库操作Service实现
 * @createDate 2024-11-19 10:10:05
 */
@Service
@RequiredArgsConstructor
public class SysOperationLogServiceImpl extends ServiceImpl<SysOperationLogMapper, SysOperationLog>
        implements SysOperationLogService {
    final SysUserService sysUserService;

    @Override
    public ResultVo<?> getLogList() {
        SysUser sysUser = this.sysUserService.getUserByLoginId().getData();
        QueryWrapper<SysOperationLog> queryWrapper = new QueryWrapper<>();
        queryWrapper.lambda().eq(SysOperationLog::getCreateUser, sysUser.getCreateUser())
                .orderByDesc(SysOperationLog::getCreatedTime)
                .last("LIMIT 8");
        List<SysOperationLog> list = this.list(queryWrapper);
        return ResultVo.success(list);
    }
}




